
$(function() {
    $('tbody tr td#click').click(function() {
      	$('#navigation li:nth-child(3) a').click();
        
        $this     = $(this).parent();
        $block_id = $this.children('td:nth-child(1)').text();
        $title    = $this.children('td:nth-child(2)').text();
        $class    = $this.children('td:nth-child(3)').text();
        $tpl      = $this.children('td:nth-child(4)').text();
        $lng      = $this.children('td:nth-child(5)').text();
        $css      = $this.children('td:nth-child(7)').text();
        $js       = $this.children('td:nth-child(6)').text();
        
        $('#block_id').val(jQuery.trim($block_id));
        $('#edit_title').val(jQuery.trim($title));
        $('#edit_class').val(jQuery.trim($class));
        $('#edit_template').val(jQuery.trim($tpl));
        $('#edit_language').val(jQuery.trim($lng));
        $('#edit_language').val(jQuery.trim($lng));
        $('#edit_JS').val(jQuery.trim($js));
        $('#edit_CSS').val(jQuery.trim($css));
        
    });
    
    $('.edit').click(function() {
      	$('#navigation li:nth-child(3) a').click();
        
        $this     = $(this).parent().parent();
        $block_id = $this.children('td:nth-child(1)').text();
        $title    = $this.children('td:nth-child(2)').text();
        $class    = $this.children('td:nth-child(3)').text();
        $tpl      = $this.children('td:nth-child(4)').text();
        $lng      = $this.children('td:nth-child(5)').text();
        $css      = $this.children('td:nth-child(7)').text();
        $js       = $this.children('td:nth-child(6)').text();
        
        $('#block_id').val(jQuery.trim($block_id));
        $('#edit_title').val(jQuery.trim($title));
        $('#edit_class').val(jQuery.trim($class));
        $('#edit_template').val(jQuery.trim($tpl));
        $('#edit_language').val(jQuery.trim($lng));
        $('#edit_language').val(jQuery.trim($lng));
        $('#edit_JS').val(jQuery.trim($js));
        $('#edit_CSS').val(jQuery.trim($css));
        
    });
    
    
    
    $('#show_groups').click(function(){
        $(this).toggle(0);
        $('#group').toggle(300, function() {$('#group').focus()});
    });
    
    $('#group').blur(function(){
        $(this).toggle(300);
        $('#show_groups').toggle(0);
    });
    
    $('#cancel').click(function(){
        $('#navigation li:nth-child(1) a').click();
    })
    
    $('#insert').click(function(){
        $('#navigation li:nth-child(2) a').click();
    })
    
    $('#cancel2').click(function(){
        $('#navigation li:nth-child(1) a').click();
    })
    
    
    
});



